<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_Booking_entity{
	var $id = 0;
	var $account_code = "";
	var $show_ref_no = "";
	var $booking_for = "";
	var $country = "";
	var $city = "";
	var $venue = "";
	var $address = "";
	var $capacity = "";
	var $ticket_price = "";
	var $potential_sponsors = "";
	
	function __destruct() {}
	function __construct() {}
    
	function is_set_array($account_code, $show_ref_no){
		$ci=& get_instance();
		
		$result = $ci->db->where( array('account_code'=>$account_code, 'show_ref_no'=>$show_ref_no ) )->get(TBL_BOOKING_FOR)->result();
		if(!empty($result)){
			return $result;
		}else{
			return false;
		}
	}
	
	function init($cmd, $input)
	{
		$ci=& get_instance();
		
		if($cmd == 'id')
		{
			$result = $ci->db->where('id',$input)->get(TBL_BOOKING_FOR)->result();
		}
		else
		{
			return false;
		}
		
		if( !empty($result) )
		{
			$this->id = $result[0]->id;
			$this->account_code = $result[0]->account_code;
			$this->show_ref_no = $result[0]->show_ref_no;
			$this->booking_for = $result[0]->booking_for;
			$this->country = $result[0]->country;
			$this->city = $result[0]->city;
			$this->venue = $result[0]->venue;
			$this->address = $result[0]->address;
			$this->capacity = $result[0]->capacity;
			$this->ticket_price = $result[0]->ticket_price;
			$this->potential_sponsors = $result[0]->potential_sponsors;
			
			return $this;
		}
		return false;
	}
	
	function setAccountCode($input){ $this->account_code=$input; }
	function setShowRefNo($input){ $this->show_ref_no=$input; }
	function setBookingFor($input){ $this->booking_for=$input; }
	function setCountry($input){ $this->country=$input; }
	function setCity($input){ $this->city=$input; }
	function setVenue($input){ $this->venue = $input; }
	function setAddress($input){ $this->address=$input; }
	function setCapacity($input){ $this->capacity=$input; }
	function setTicketPrice($input){ $this->ticket_price=$input; }
	function setPotentialSponsors($input){ $this->potential_sponsors=$input; }
	
	function getId(){ return $this->id; }
	function getAccountCode(){ return $this->account_code; }
	function getShowRefNo(){ return $this->show_ref_no; }
	function getBookingFor() { return $this->booking_for;}
	function getCountry() { return $this->country;}
	function getCity(){ return $this->city;}
	function getVenue(){ return $this->venue;}
	function getAddress(){ return $this->address; }
	function getCapacity(){ return $this->capacity; }
	function getTicketPrice(){ return $this->ticket_price; }
	function getPotentialSponsors(){ return $this->potential_sponsors; }
	
	
	function update()
	{
		$ci=& get_instance();
	
		$ci->db->set('account_code', $this->account_code);
		$ci->db->set('show_ref_no', $this->show_ref_no);
		$ci->db->set('booking_for', $this->booking_for);
		$ci->db->set('country', $this->country);
		$ci->db->set('city', $this->city);
		$ci->db->set('venue', $this->venue);
		$ci->db->set('address', $this->address);
		$ci->db->set('capacity', $this->capacity);
		$ci->db->set('ticket_price', $this->ticket_price);
		$ci->db->set('potential_sponsors', $this->potential_sponsors);
		
		$ci->db->where('id', $this->id)->update(TBL_BOOKING_FOR);
	}
	
	function createNewBookingEntity($account_code, $show_ref_no){
		$ci=& get_instance();
		
		$ci->db->set('account_code', $account_code);
		$ci->db->set('show_ref_no', $show_ref_no);
	
		$ci->db->insert(TBL_BOOKING_FOR);
		
		return $ci->db->insert_id();
	}
	
	
}
